package cn.lyq.card.data.api

import cn.lyq.card.data.model.*
import cn.lyq.card.global.Const
import com.google.gson.JsonObject
import okhttp3.RequestBody
import retrofit2.http.*

interface UserService {

    @POST("api/v1/login")
    @FormUrlEncoded
    suspend fun login(
        @Field("user_name") user_name: String,
        @Field("password") password: String
    ): ResponseInfo<TokenInfo>

    /**
     * @param type 1 => ",您正尝试设置新的密码，若非本人操作，请勿泄露。",
     * 2 => ",您正在尝试变更您的密码，请妥善保管账户信息。",
     * 3 => ",您正尝试修改您的电话号码，若非本人操作，请勿泄露。",
     * 4 => ",您正尝试添加银行卡，若非本人操作，请勿泄露。",
     * 5 => ",您正在注册成为新用户，感谢您的支持！",
     * 6 => ",您正在尝试变更重要信息，请妥善保管账户信息。"
     */
    @POST("api/v1/get_code")
    @FormUrlEncoded
    suspend fun getCode(
        @Field("user_name") user_name: String,
        @Field("type") type: String,
        @Field("exist_need") exist_need: Int = 1
    ): ResponseInfo<Nothing>

    /**
     * @param type 1 => ",您正尝试设置新的密码，若非本人操作，请勿泄露。",
     * 2 => ",您正在尝试变更您的密码，请妥善保管账户信息。",
     * 3 => ",您正尝试修改您的电话号码，若非本人操作，请勿泄露。",
     * 4 => ",您正尝试添加银行卡，若非本人操作，请勿泄露。",
     * 5 => ",您正在注册成为新用户，感谢您的支持！",
     * 6 => ",您正在尝试变更重要信息，请妥善保管账户信息。"
     */
    @POST("api/v1/send_code")
    @FormUrlEncoded
    suspend fun sendCode(
        @Field("type") type: String,
        @Header("token") token: String = Const.token,
        @Field("exist_need") exist_need: Int = 1
    ): ResponseInfo<Nothing>

    @POST("api/v1/userInfo")
    suspend fun getUserInfo(
        @Header("token") token: String = Const.token
    ): ResponseInfo<UserInfo>

    @POST("api/v1/editUserInfo")
    @FormUrlEncoded
    suspend fun editUserInfo(
        @Field("user_icon") userIcon: String,
        @Field("agent_name") agentName: String,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/upWithdrawPassword")
    @FormUrlEncoded
    suspend fun upWithdrawPassword(
        @Field("user_name") phone: String,
        @Field("password") password: String,
        @Field("code") code: String,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/upLoginPassword")
    @FormUrlEncoded
    suspend fun upLoginPassword(
        @Field("user_name") phone: String,
        @Field("password") password: String,
        @Field("code") code: String,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/forgetPassword")
    @FormUrlEncoded
    suspend fun forgetPassword(
        @Field("user_name") user_name: String,
        @Field("password") password: String,
        @Field("code") code: String
    ): ResponseInfo<Nothing>

    @POST("api/v1/notice")
    @FormUrlEncoded
    suspend fun getNotice(
        @Field("page") page: Int,
        @Field("pagesize") Int: Int,
        @Field("type") type: Int,
        @Header("token") token: String = Const.token
    ): ResponseInfo<MsgWrapInfo<MsgSysInfo>>

    @POST("api/v1/noticeRead")
    suspend fun setAllNoticeRead(
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/noticeReadWhereId")
    @FormUrlEncoded
    suspend fun setNoticeRead(
        @Field("notice_id") id: Int,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/address")
    suspend fun getAddressList(
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<AddressInfo>>

    @POST("api/v1/addressEdit")
    @FormUrlEncoded
    suspend fun editAddress(
        @Field("truename") truename: String,
        @Field("mobile") mobile: String,
        @Field("address") address: String,
        @Field("details_address") details_address: String,
        @Field("default") default: Int = 0,
        @Field("id") id: String = "",
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/addressDelete")
    @FormUrlEncoded
    suspend fun delAddress(
        @Field("address_id") id: String = "",
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>


    @POST("api/v1/getRegions")
    @FormUrlEncoded
    suspend fun getRegions(
        @Field("parent_id") parentId: String = "",
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<AreaInfo>>

    @POST("api/v1/bank_card_info")
    suspend fun getBankCardInfo(
        @Header("token") token: String = Const.token
    ): ResponseInfo<BankCardInfo>

    @POST("api/v1/bank_list")
    @FormUrlEncoded
    suspend fun getBankList(
        @Field("keyword") keyword: String = "",
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<BankInfo>>

    @POST("api/v1/bank_card_edit")
    @FormUrlEncoded
    suspend fun editBankCard(
        @Field("card_number") card_number: String = "",
        @Field("bank_id") bank_id: Int,
        @Field("phone") phone: String = "",
        @Field("code") code: String,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/bill_type")
    suspend fun getBillType(
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<BillTypeInfo>>

    @POST("api/v1/bill")
    @FormUrlEncoded
    suspend fun getBill(
        @Field("page") page: Int,
        @Field("pagesize") pageSize: Int,
        @Field("type") type: String = "0",
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<BillInfo>>

    @POST("api/v1/cashApply")
    @FormUrlEncoded
    suspend fun applyCash(
        @Field("price") price: String,
        @Field("password") password: String,
        @Field("type") type: Int,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/cash")
    @FormUrlEncoded
    suspend fun getCashRecord(
        @Field("page") page: Int,
        @Field("pagesize") pageSize: Int,
        @Field("type") type: Int,
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<CashRecordInfo>>

    @POST("api/v1/account")
    suspend fun getWalletInfo(
        @Header("token") token: String = Const.token
    ): ResponseInfo<WalletInfo>

    @POST("api/v1/userCertification")
    @FormUrlEncoded
    suspend fun verifyTrueName(
        @Field("name") name: String,
        @Field("idcode") idCode: String,
        @Field("bank_card") bank_card: String,
        @Field("code") code: String,
        @Field("img_id") imgId: String,
        @Field("img_id_reverse") imgIdReverse: String,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/feedback")
    @FormUrlEncoded
    suspend fun addFeedback(
        @Field("feedback") feedback: String,
        @Header("token") token: String = Const.token
    ): ResponseInfo<Nothing>

    @POST("api/v1/commonProblem")
    @FormUrlEncoded
    suspend fun getCommonProblem(
        @Field("page") page: Int,
        @Field("pagesize") pageSize: Int,
        @Field("keyword") keyword: String = "",
        @Header("token") token: String = Const.token
    ): ResponseInfo<MutableList<ProblemInfo>>

    @POST("api/v1/about_us")
    suspend fun getAboutUs(
        @Header("token") token: String = Const.token
    ): ResponseInfo<AboutUsInfo>

    @POST("api/v1/versionInformation")
    @FormUrlEncoded
    suspend fun getApp(
        @Field("system") system: String = "android",
        @Header("token") token: String = Const.token
    ): ResponseInfo<AppInfo>

    @POST("api/v1/uploadImage")
    suspend fun upload(
        @Body Body: RequestBody,
        @Header("token") token: String = Const.token
    ): ResponseInfo<UploadInfo>

}